package lab03.test07;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Test {
    public static void main(String[] args) {
        String path = "E:\\test.zip";
        try {
            ZipFile zipFile = new ZipFile(path);
            Enumeration entries = zipFile.entries();
            ZipEntry zipEntry = null;


            while (entries.hasMoreElements()) {
                zipEntry = (ZipEntry) entries.nextElement();
                System.out.println(zipEntry.getName());


                File testfile = new File("E:\\test");
                testfile.mkdir();



                InputStream fileinputStream = zipFile.getInputStream(zipEntry);
                FileOutputStream fileOutputStream = new FileOutputStream("E:\\test\\" + zipEntry.getName());

                byte[] data = new byte[1024];
                while (fileinputStream.read(data) != -1) {
                    fileOutputStream.write(data);
                }
                fileinputStream.close();
                fileOutputStream.close();


            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
